﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Text;
using BestTrader.Cms.Core;
using BestTrader.Cms.Core.Helper;
using BestTrader.Cms.Core.Options;
using BestTrader.Cms.Models;
using BestTrader.Cms.RmmfSoftService;
using BestTrader.Cms.RmmfSoftServices.Models;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;

namespace BestTrader.Cms.RmmfSoftServices
{

    public class RmmfSoftAccountService
    {
        protected RmmsoftOption _options;

        public RmmfSoftAccountService(IOptionsSnapshot<RmmsoftOption> options)
        {
            _options = options.Get("RMMSOFT");
            if (_options == null)
            {
                throw new ArgumentNullException(nameof(RmmsoftOption));
            }
        }

        /// <summary>
        /// 风软管理员角色 
        /// </summary>
        public Int32 RmmfAdminRoleID
        {
            get { return 2; }
        }

        /// <summary>
        /// 风软普通用户角色 
        /// </summary>
        public Int32 RmmfCustomerRoleID
        {
            get { return 1; }
        }

        /// <summary>
        /// 角色转换（系统->风软）
        /// </summary>
        public String TraderRoleToRmmfFirmStructureID
        {
            get
            {
                var depts = CacheHelper.Get<List<FirmStructureModel>>(Constants.CACHE_RMMSOFT_DEPTS);
                if (depts == null || !depts.Any())
                {
                    depts = GetFirmStructure();
                    CacheHelper.Set(Constants.CACHE_RMMSOFT_DEPTS, depts);
                }

                return depts.FirstOrDefault(p => p.IsLeaf).NodeID;
            }
        }

        /// <summary>
        /// 角色转换（系统->风软）
        /// </summary>
        public String AddRmmfFirmStructureByRoleId(Manager manager, string parentUserName)
        {
            // 直客
            if (manager.RoleId == 6)
            {
                //var depts = GetFirmStructure();
                //fsModel = depts.FirstOrDefault(p => p.IsLeaf && p.NodeID == parentUserName);
                //if (fsModel == null)
                //{
                //    fsModel = depts.FirstOrDefault(p => p.IsLeaf);
                //}
                return parentUserName;
            }
            else
            {
                //代理  李明勋 3月17号 提出注册代理级别应该是2.
                var fsModel = new FirmStructureModel
                {
                    IsLeaf = true,
                    NodeLevel = 2,
                    ParentNode = "LV001",
                    NodeID = manager.UserName,
                    NodeName = $"{manager.RealName}({manager.UserName})"
                };
                // 代理需要注册组织机构
                var flag = InsertFirmStructure(fsModel);
                return fsModel.NodeID;
            }
            
        }

        public List<ActiveAccountInfoOutput> GetActiveAccountInfo()
        {
            var result = new List<ActiveAccountInfoOutput>();

            // 创建 HTTP 绑定对象
            var binding = new BasicHttpBinding();
            //设置最大传输接受数量
            binding.MaxReceivedMessageSize = 2147483647;
            // 根据 WebService 的 URL 构建终端点对象
            var endpoint = new EndpointAddress(_options.BaseUrl);
            // 创建调用接口的工厂，注意这里泛型只能传入接口 添加服务引用时生成的 webservice的接口 一般是 (XXXSoap)
            var factory = new ChannelFactory<WebServiceAPISoap>(binding, endpoint);
            // 从工厂获取具体的调用实例
            var callClient = factory.CreateChannel();
            //调用的对应webservice 服务类的函数生成对应的请求类Body (一般是webservice 中对应的方法+RequestBody  如GetInfoListRequestBody)
            GetActiveAccountInfoRequestBody body = new GetActiveAccountInfoRequestBody();
            //以下是为该请求body添加对应的参数（就是调用webService中对应的方法的参数）

            //获取请求对象 （一般是webservice 中对应的方法+tRequest  如GetInfoListRequest）
            var request = new GetActiveAccountInfoRequest(body);
            //发送请求
            var v = callClient.GetActiveAccountInfoAsync(request);
            //异步等待
            v.Wait();
            //获取数据
            result = JsonConvert.DeserializeObject<List<ActiveAccountInfoOutput>>(v.Result.Body.GetActiveAccountInfoResult);

            return result;
        }

        public List<UserRoleOutput> GetAllUserRoles()
        {
            var result = new List<UserRoleOutput>();

            // 创建 HTTP 绑定对象
            var binding = new BasicHttpBinding();
            //设置最大传输接受数量
            binding.MaxReceivedMessageSize = 2147483647;
            // 根据 WebService 的 URL 构建终端点对象
            var endpoint = new EndpointAddress(_options.BaseUrl);
            // 创建调用接口的工厂，注意这里泛型只能传入接口 添加服务引用时生成的 webservice的接口 一般是 (XXXSoap)
            var factory = new ChannelFactory<WebServiceAPISoap>(binding, endpoint);
            // 从工厂获取具体的调用实例
            var callClient = factory.CreateChannel();
            //调用的对应webservice 服务类的函数生成对应的请求类Body (一般是webservice 中对应的方法+RequestBody  如GetInfoListRequestBody)
            var body = new GetAllUserRolesRequestBody();
            //以下是为该请求body添加对应的参数（就是调用webService中对应的方法的参数）

            //获取请求对象 （一般是webservice 中对应的方法+tRequest  如GetInfoListRequest）
            var request = new GetAllUserRolesRequest(body);
            //发送请求
            var v = callClient.GetAllUserRolesAsync(request);
            //异步等待
            v.Wait();
            //获取数据
            result = JsonConvert.DeserializeObject<List<UserRoleOutput>>(v.Result.Body.GetAllUserRolesResult);

            return result;
        }

        public Int32 AddCustomer(CustomerInput input) {
            Int32 result = -5;

            // 创建 HTTP 绑定对象
            var binding = new BasicHttpBinding();
            //设置最大传输接受数量
            binding.MaxReceivedMessageSize = 2147483647;
            // 根据 WebService 的 URL 构建终端点对象
            var endpoint = new EndpointAddress(_options.BaseUrl);
            // 创建调用接口的工厂，注意这里泛型只能传入接口 添加服务引用时生成的 webservice的接口 一般是 (XXXSoap)
            var factory = new ChannelFactory<WebServiceAPISoap>(binding, endpoint);
            // 从工厂获取具体的调用实例
            var callClient = factory.CreateChannel();

            //调用的对应webservice 服务类的函数生成对应的请求类Body (一般是webservice 中对应的方法+RequestBody  如GetInfoListRequestBody)
            AddCustomerRequestBody body = new AddCustomerRequestBody();
            body.jsonCustomer = JsonConvert.SerializeObject(input);

            //获取请求对象 （一般是webservice 中对应的方法+tRequest  如GetInfoListRequest）
            var request = new AddCustomerRequest(body);
            //发送请求
            var v = callClient.AddCustomerAsync(request);
            //异步等待
            v.Wait();
            //获取数据
            // UserID, -4:转换账户信息失败，-3:创建账户失败，-2:LoginName重复，-1:添加失败
            result = v.Result.Body.AddCustomerResult;
            return result;
        }

        #region FirmStructure

        public List<FirmStructureModel> GetFirmStructure()
        {
            var result = new List<FirmStructureModel>();

            // 创建 HTTP 绑定对象
            var binding = new BasicHttpBinding();
            //设置最大传输接受数量
            binding.MaxReceivedMessageSize = 2147483647;
            // 根据 WebService 的 URL 构建终端点对象
            var endpoint = new EndpointAddress(_options.BaseUrl);
            // 创建调用接口的工厂，注意这里泛型只能传入接口 添加服务引用时生成的 webservice的接口 一般是 (XXXSoap)
            var factory = new ChannelFactory<WebServiceAPISoap>(binding, endpoint);
            // 从工厂获取具体的调用实例
            var callClient = factory.CreateChannel();
            //调用的对应webservice 服务类的函数生成对应的请求类Body (一般是webservice 中对应的方法+RequestBody  如GetInfoListRequestBody)
            var body = new GetFirmStructureRequestBody();
            //以下是为该请求body添加对应的参数（就是调用webService中对应的方法的参数）

            //获取请求对象 （一般是webservice 中对应的方法+tRequest  如GetInfoListRequest）
            var request = new GetFirmStructureRequest(body);
            //发送请求
            var v = callClient.GetFirmStructureAsync(request);
            //异步等待
            v.Wait();
            //获取数据
            result = JsonConvert.DeserializeObject<List<FirmStructureModel>>(v.Result.Body.GetFirmStructureResult);

            return result;
        }

        public Boolean InsertFirmStructure(FirmStructureModel input)
        {
            var binding = new BasicHttpBinding();
            //设置最大传输接受数量
            binding.MaxReceivedMessageSize = 2147483647;
            // 根据 WebService 的 URL 构建终端点对象
            var endpoint = new EndpointAddress(_options.BaseUrl);
            // 创建调用接口的工厂，注意这里泛型只能传入接口 添加服务引用时生成的 webservice的接口 一般是 (XXXSoap)
            var factory = new ChannelFactory<WebServiceAPISoap>(binding, endpoint);
            // 从工厂获取具体的调用实例
            var callClient = factory.CreateChannel();
            //调用的对应webservice 服务类的函数生成对应的请求类Body (一般是webservice 中对应的方法+RequestBody  如GetInfoListRequestBody)
            InsertFirmStructureRequestBody body = new InsertFirmStructureRequestBody();
            //以下是为该请求body添加对应的参数（就是调用webService中对应的方法的参数）
            body.jsonFirmStructure = JsonConvert.SerializeObject(input);

            //获取请求对象 （一般是webservice 中对应的方法+tRequest  如GetInfoListRequest）
            var request = new InsertFirmStructureRequest(body);
            //发送请求
            var v = callClient.InsertFirmStructureAsync(request);
            //异步等待
            v.Wait();
            //获取数据
            // 0：成功；-1:添加失败
            return v.Result.Body.InsertFirmStructureResult >=0;
        }

        public Boolean UpdateFirmStructure(FirmStructureModel input, string oldNodeID)
        {
            var binding = new BasicHttpBinding();
            //设置最大传输接受数量
            binding.MaxReceivedMessageSize = 2147483647;
            // 根据 WebService 的 URL 构建终端点对象
            var endpoint = new EndpointAddress(_options.BaseUrl);
            // 创建调用接口的工厂，注意这里泛型只能传入接口 添加服务引用时生成的 webservice的接口 一般是 (XXXSoap)
            var factory = new ChannelFactory<WebServiceAPISoap>(binding, endpoint);
            // 从工厂获取具体的调用实例
            var callClient = factory.CreateChannel();
            //调用的对应webservice 服务类的函数生成对应的请求类Body (一般是webservice 中对应的方法+RequestBody  如GetInfoListRequestBody)
            UpdateFirmStructureRequestBody body = new UpdateFirmStructureRequestBody();
            //以下是为该请求body添加对应的参数（就是调用webService中对应的方法的参数）
            body.jsonFirmStructure = JsonConvert.SerializeObject(input);
            body.oldNodeID = oldNodeID;

            //获取请求对象 （一般是webservice 中对应的方法+tRequest  如GetInfoListRequest）
            var request = new UpdateFirmStructureRequest(body);
            //发送请求
            var v = callClient.UpdateFirmStructureAsync(request);
            //异步等待
            v.Wait();
            //获取数据
            // 0：成功；-1:添加失败
            return v.Result.Body.UpdateFirmStructureResult >= 0;
        }

        public String ResetLoginUserPassword(int loginUserID)
        {
            var binding = new BasicHttpBinding();
            //设置最大传输接受数量
            binding.MaxReceivedMessageSize = 2147483647;
            // 根据 WebService 的 URL 构建终端点对象
            var endpoint = new EndpointAddress(_options.BaseUrl);
            // 创建调用接口的工厂，注意这里泛型只能传入接口 添加服务引用时生成的 webservice的接口 一般是 (XXXSoap)
            var factory = new ChannelFactory<WebServiceAPISoap>(binding, endpoint);
            // 从工厂获取具体的调用实例
            var callClient = factory.CreateChannel();
            //调用的对应webservice 服务类的函数生成对应的请求类Body (一般是webservice 中对应的方法+RequestBody  如GetInfoListRequestBody)
            ResetLoginUserPasswordRequestBody body = new ResetLoginUserPasswordRequestBody();
            //以下是为该请求body添加对应的参数（就是调用webService中对应的方法的参数）
            body.loginUserID = loginUserID;

            //获取请求对象 （一般是webservice 中对应的方法+tRequest  如GetInfoListRequest）
            var request = new ResetLoginUserPasswordRequest(body);
            //发送请求
            var v = callClient.ResetLoginUserPasswordAsync(request);
            //异步等待
            v.Wait();
            //获取数据
            // 0：成功；-1:添加失败
            return v.Result.Body.ResetLoginUserPasswordResult;
        }

        /// <summary>
        /// GetActiveAccountInfo
        /// </summary>
        public List<SettlementReportOutput> GetSettlementReport(string loginUserName)
        {
            //{ "dtHasOrder":[{"AccountName":"BT00301","WorkingOrders":false},{"AccountName":"QS1003001","WorkingOrders":false},{"AccountName":"QS1005401","WorkingOrders":false},{"AccountName":"QS1005301","WorkingOrders":false},{"AccountName":"QS1005201","WorkingOrders":false},{"AccountName":"QS1005501","WorkingOrders":false},{"AccountName":"QS1005701","WorkingOrders":false},{"AccountName":"GT1003301","WorkingOrders":false},{"AccountName":"bt00401","WorkingOrders":false},{"AccountName":"QS1005801","WorkingOrders":false},{"AccountName":"QS1006001","WorkingOrders":false},{"AccountName":"bt00801","WorkingOrders":false},{"AccountName":"gt10001","WorkingOrders":false},{"AccountName":"GT1003201","WorkingOrders":false},{"AccountName":"ZH0001","WorkingOrders":false},{"AccountName":"HKYIFUTEST","WorkingOrders":false},{"AccountName":"gt0102501","WorkingOrders":false},{"AccountName":"liuhejia101","WorkingOrders":false},{"AccountName":"NGS1000801","WorkingOrders":false},{"AccountName":"NGS1000901","WorkingOrders":false},{"AccountName":"QS1000601","WorkingOrders":false},{"AccountName":"gt020801","WorkingOrders":false},{"AccountName":"QS1000701","WorkingOrders":false},{"AccountName":"QS1000801","WorkingOrders":false},{"AccountName":"QS1000901","WorkingOrders":false},{"AccountName":"LL12345601","WorkingOrders":false},{"AccountName":"QS1001101","WorkingOrders":false},{"AccountName":"qwert01","WorkingOrders":false},{"AccountName":"QS1001301","WorkingOrders":false},{"AccountName":"LLL66601","WorkingOrders":false},{"AccountName":"GT31501","WorkingOrders":false},{"AccountName":"LLL33301","WorkingOrders":false},{"AccountName":"XXX11101","WorkingOrders":false},{"AccountName":"QS1002601","WorkingOrders":false},{"AccountName":"QS1002501","WorkingOrders":false},{"AccountName":"simon00101","WorkingOrders":false},{"AccountName":"simon00201","WorkingOrders":false},{"AccountName":"QS1002801","WorkingOrders":false},{"AccountName":"QS1002901","WorkingOrders":false},{"AccountName":"qwert101","WorkingOrders":false},{"AccountName":"QS1003101","WorkingOrders":false},{"AccountName":"QS1003201","WorkingOrders":false},{"AccountName":"QS1003301","WorkingOrders":false},{"AccountName":"XXX22201","WorkingOrders":false},{"AccountName":"QS1003501","WorkingOrders":false},{"AccountName":"XXX33301","WorkingOrders":false},{"AccountName":"qwert201","WorkingOrders":false},{"AccountName":"QS1003801","WorkingOrders":false},{"AccountName":"QS1003901","WorkingOrders":false},{"AccountName":"QS1004001","WorkingOrders":false},{"AccountName":"QS1004101","WorkingOrders":false},{"AccountName":"qs10101","WorkingOrders":false},{"AccountName":"QS1004301","WorkingOrders":false},{"AccountName":"QS1004401","WorkingOrders":false},{"AccountName":"QS1004501","WorkingOrders":false},{"AccountName":"qs10201","WorkingOrders":false},{"AccountName":"QS1004701","WorkingOrders":false},{"AccountName":"QS1004801","WorkingOrders":false},{"AccountName":"QS1004901","WorkingOrders":false},{"AccountName":"QS1005001","WorkingOrders":false},{"AccountName":"qs000101","WorkingOrders":false},{"AccountName":"qs000201","WorkingOrders":false},{"AccountName":"FRTEST0101","WorkingOrders":true},{"AccountName":"FRTEST0201","WorkingOrders":false},{"AccountName":"FRTEST03","WorkingOrders":true},{"AccountName":"whcj0101","WorkingOrders":false},{"AccountName":"whcj0201","WorkingOrders":false}],"dtCC":[{"AccountName":"bt00401","SecurityDesc":"HK.HSI.F.190300","PosSide":"2","Quantity":594,"DealedPrice":28311,"LastPrice":28271,"LastTradingDate":20190328},{"AccountName":"bt00401","SecurityDesc":"CBT.C.F.190300","PosSide":"2","Quantity":99,"DealedPrice":374.25,"LastPrice":375.75,"LastTradingDate":20190314},{"AccountName":"bt00401","SecurityDesc":"CBT.W.F.190300","PosSide":"1","Quantity":101,"DealedPrice":523.72029703,"LastPrice":503.5,"LastTradingDate":20190314},{"AccountName":"bt00401","SecurityDesc":"CBT.WE.F.190300","PosSide":"1","Quantity":1,"DealedPrice":532,"LastPrice":503.25,"LastTradingDate":20190314},{"AccountName":"QS1005801","SecurityDesc":"HK.HHI.F.190300","PosSide":"1","Quantity":1,"DealedPrice":11139,"LastPrice":11169,"LastTradingDate":20190328},{"AccountName":"QS1005801","SecurityDesc":"HK.HSI.F.190300","PosSide":"1","Quantity":2,"DealedPrice":28306,"LastPrice":28271,"LastTradingDate":20190328},{"AccountName":"QS1005801","SecurityDesc":"HK.MHI.F.190300","PosSide":"1","Quantity":5,"DealedPrice":28309,"LastPrice":28261,"LastTradingDate":20190328},{"AccountName":"QS1005801","SecurityDesc":"CBT.BO.F.190300","PosSide":"1","Quantity":10,"DealedPrice":30.08,"LastPrice":30.21,"LastTradingDate":20190314},{"AccountName":"QS1006001","SecurityDesc":"HK.HSI.F.190300","PosSide":"1","Quantity":1,"DealedPrice":28320,"LastPrice":28271,"LastTradingDate":20190328},{"AccountName":"QS1006001","SecurityDesc":"HK.MHI.F.190300","PosSide":"1","Quantity":1,"DealedPrice":28320,"LastPrice":28261,"LastTradingDate":20190328},{"AccountName":"QS1006001","SecurityDesc":"CBT.CE.F.190300","PosSide":"1","Quantity":1,"DealedPrice":376.625,"LastPrice":375.875,"LastTradingDate":20190314},{"AccountName":"ZH0001","SecurityDesc":"CMX.GC.F.190200","PosSide":"1","Quantity":1,"DealedPrice":1282,"LastPrice":1324.2,"LastTradingDate":20190226},{"AccountName":"ZH0001","SecurityDesc":"CMX.HG.F.190300","PosSide":"1","Quantity":1,"DealedPrice":2.6595,"LastPrice":2.8325,"LastTradingDate":20190327},{"AccountName":"ZH0001","SecurityDesc":"CMX.SI.F.190300","PosSide":"1","Quantity":1,"DealedPrice":15.365,"LastPrice":15.75,"LastTradingDate":20190327},{"AccountName":"ZH0001","SecurityDesc":"SG.CN.F.190200","PosSide":"1","Quantity":1,"DealedPrice":11047.5,"LastPrice":11837.5,"LastTradingDate":20190227},{"AccountName":"ZH0001","SecurityDesc":"SG.NS.F.190300","PosSide":"1","Quantity":3,"DealedPrice":20520,"LastPrice":21295,"LastTradingDate":20190308},{"AccountName":"ZH0001","SecurityDesc":"NYM.QM.F.190300","PosSide":"1","Quantity":2,"DealedPrice":52.45,"LastPrice":55.8,"LastTradingDate":20190219},{"AccountName":"ZH0001","SecurityDesc":"NYM.PA.F.190300","PosSide":"1","Quantity":1,"DealedPrice":1311.9,"LastPrice":1445.1,"LastTradingDate":20190327},{"AccountName":"ZH0001","SecurityDesc":"NYM.PL.F.190400","PosSide":"1","Quantity":1,"DealedPrice":798,"LastPrice":810.5,"LastTradingDate":20190426},{"AccountName":"ZH0001","SecurityDesc":"NYM.CL.F.190300","PosSide":"1","Quantity":1,"DealedPrice":52.43,"LastPrice":55.83,"LastTradingDate":20190220},{"AccountName":"ZH0001","SecurityDesc":"CME.NQ.F.190300","PosSide":"1","Quantity":1,"DealedPrice":6674,"LastPrice":7072.5,"LastTradingDate":20190315},{"AccountName":"ZH0001","SecurityDesc":"IPE.BRN.F.190300","PosSide":"1","Quantity":2,"DealedPrice":60.94,"LastPrice":61.26,"LastTradingDate":20190300},{"AccountName":"QS1002801","SecurityDesc":"CME.AD.F.190300","PosSide":"2","Quantity":3,"DealedPrice":0.7075,"LastPrice":0.7118,"LastTradingDate":20190318},{"AccountName":"QS1002801","SecurityDesc":"CME.EC.F.190300","PosSide":"1","Quantity":2,"DealedPrice":1.131,"LastPrice":1.13235,"LastTradingDate":20190318},{"AccountName":"QS1002801","SecurityDesc":"HK.HSI.F.190300","PosSide":"1","Quantity":3,"DealedPrice":28396,"LastPrice":28271,"LastTradingDate":20190328},{"AccountName":"QS1002801","SecurityDesc":"HK.MHI.F.190200","PosSide":"1","Quantity":10,"DealedPrice":28405,"LastPrice":28257,"LastTradingDate":20190227},{"AccountName":"QS1002801","SecurityDesc":"CBT.BO.F.190300","PosSide":"2","Quantity":4,"DealedPrice":30.75,"LastPrice":30.21,"LastTradingDate":20190314},{"AccountName":"QS1002801","SecurityDesc":"CBT.CE.F.190300","PosSide":"1","Quantity":5,"DealedPrice":387.75,"LastPrice":375.875,"LastTradingDate":20190314},{"AccountName":"QS1002801","SecurityDesc":"CBT.S.F.190300","PosSide":"2","Quantity":5,"DealedPrice":916.115,"LastPrice":909.75,"LastTradingDate":20190314},{"AccountName":"QS1002801","SecurityDesc":"CBT.S.F.190500","PosSide":"2","Quantity":9,"DealedPrice":930.605,"LastPrice":923.5,"LastTradingDate":20190514},{"AccountName":"QS1002901","SecurityDesc":"HK.HHI.F.190300","PosSide":"1","Quantity":1,"DealedPrice":11271,"LastPrice":11169,"LastTradingDate":20190328},{"AccountName":"QS1002901","SecurityDesc":"HK.HSI.F.190300","PosSide":"1","Quantity":2,"DealedPrice":28398,"LastPrice":28271,"LastTradingDate":20190328},{"AccountName":"QS1002901","SecurityDesc":"HK.MHI.F.190200","PosSide":"1","Quantity":5,"DealedPrice":28404,"LastPrice":28257,"LastTradingDate":20190227},{"AccountName":"QS1002901","SecurityDesc":"CBT.BO.F.190300","PosSide":"1","Quantity":1,"DealedPrice":30.75,"LastPrice":30.21,"LastTradingDate":20190314},{"AccountName":"QS1003101","SecurityDesc":"HK.HHI.F.190300","PosSide":"1","Quantity":51,"DealedPrice":11267.15686275,"LastPrice":11169,"LastTradingDate":20190328},{"AccountName":"QS1003101","SecurityDesc":"HK.HSI.F.190300","PosSide":"1","Quantity":6,"DealedPrice":28409.16666667,"LastPrice":28271,"LastTradingDate":20190328},{"AccountName":"QS1003101","SecurityDesc":"HK.MHI.F.190200","PosSide":"1","Quantity":104,"DealedPrice":28414.80769231,"LastPrice":28257,"LastTradingDate":20190227},{"AccountName":"QS1003101","SecurityDesc":"CBT.BO.F.190300","PosSide":"2","Quantity":1,"DealedPrice":30.58,"LastPrice":30.21,"LastTradingDate":20190314},{"AccountName":"QS1003101","SecurityDesc":"CBT.CE.F.190300","PosSide":"2","Quantity":100,"DealedPrice":387.25,"LastPrice":375.875,"LastTradingDate":20190314},{"AccountName":"QS1003101","SecurityDesc":"CBT.S.F.190300","PosSide":"2","Quantity":47,"DealedPrice":916.1075,"LastPrice":909.75,"LastTradingDate":20190314},{"AccountName":"QS1003201","SecurityDesc":"CME.ED.F.190300","PosSide":"2","Quantity":10,"DealedPrice":97.39,"LastPrice":97.3325,"LastTradingDate":20190318},{"AccountName":"QS1003201","SecurityDesc":"HK.HSI.F.190300","PosSide":"1","Quantity":100,"DealedPrice":28405,"LastPrice":28271,"LastTradingDate":20190328},{"AccountName":"QS1003201","SecurityDesc":"HK.MHI.F.190200","PosSide":"1","Quantity":100,"DealedPrice":28416,"LastPrice":28257,"LastTradingDate":20190227},{"AccountName":"QS1003201","SecurityDesc":"CBT.CE.F.190300","PosSide":"1","Quantity":101,"DealedPrice":387.25618812,"LastPrice":375.875,"LastTradingDate":20190314},{"AccountName":"QS1003201","SecurityDesc":"CBT.SM.F.190300","PosSide":"1","Quantity":26,"DealedPrice":314.69615385,"LastPrice":306.5,"LastTradingDate":20190314},{"AccountName":"FRTEST0101","SecurityDesc":"CBT.YM.F.190300","PosSide":"1","Quantity":1,"DealedPrice":24532,"LastPrice":25881,"LastTradingDate":20190315},{"AccountName":"FRTEST0101","SecurityDesc":"CME.SPE.F.190300","PosSide":"1","Quantity":1,"DealedPrice":2655,"LastPrice":2775.75,"LastTradingDate":20190315}],"dtKHZJ":[{"AccountName":"BT00301","Currency":"USD","LastAsset":0,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":0,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":0},{"AccountName":"QS1003001","Currency":"USD","LastAsset":0,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":0,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":0},{"AccountName":"QS1005401","Currency":"USD","LastAsset":0,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":0,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":0},{"AccountName":"QS1005301","Currency":"USD","LastAsset":0,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":0,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":0},{"AccountName":"QS1005201","Currency":"USD","LastAsset":0,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":0,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":0},{"AccountName":"QS1005501","Currency":"USD","LastAsset":0,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":0,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":0},{"AccountName":"QS1005701","Currency":"USD","LastAsset":0,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":0,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":0},{"AccountName":"GT1003301","Currency":"USD","LastAsset":0,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":0,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":0},{"AccountName":"bt00401","Currency":"USD","LastAsset":1075766787.92176,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":43364.0399158502,"CurrentNLV":1075810151.96167,"InitialMargin":6325719.47264028,"MaintenanceMargin":6316756.47264028,"BuyingPower":1069484432.48903},{"AccountName":"QS1005801","Currency":"USD","LastAsset":537692.224970427,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":212.633185491333,"CurrentNLV":537904.858155918,"InitialMargin":40532.9255599266,"MaintenanceMargin":40082.9255599266,"BuyingPower":497371.932595992},{"AccountName":"QS1006001","Currency":"USD","LastAsset":579876.691682873,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":-399.498890024196,"CurrentNLV":579477.192792849,"InitialMargin":12734.0696416975,"MaintenanceMargin":12720.0696416975,"BuyingPower":566743.123151151},{"AccountName":"bt00801","Currency":"USD","LastAsset":0,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":0,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":0},{"AccountName":"gt10001","Currency":"USD","LastAsset":0,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":0,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":0},{"AccountName":"GT1003201","Currency":"USD","LastAsset":0,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":0,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":0},{"AccountName":"ZH0001","Currency":"USD","LastAsset":118021.605230297,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":54989.2999462262,"CurrentNLV":173010.905176523,"InitialMargin":66767.127920623,"MaintenanceMargin":62206.479927839,"BuyingPower":107694.101252292},{"AccountName":"HKYIFUTEST","Currency":"USD","LastAsset":80000,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":80000,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":80000},{"AccountName":"gt0102501","Currency":"USD","LastAsset":0,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":0,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":0},{"AccountName":"liuhejia101","Currency":"USD","LastAsset":0,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":0,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":0},{"AccountName":"NGS1000801","Currency":"USD","LastAsset":0,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":0,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":0},{"AccountName":"NGS1000901","Currency":"USD","LastAsset":0,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":0,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":0},{"AccountName":"QS1000601","Currency":"USD","LastAsset":0,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":0,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":0},{"AccountName":"gt020801","Currency":"USD","LastAsset":0,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":0,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":0},{"AccountName":"QS1000701","Currency":"USD","LastAsset":0,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":0,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":0},{"AccountName":"QS1000801","Currency":"USD","LastAsset":0,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":0,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":0},{"AccountName":"QS1000901","Currency":"USD","LastAsset":0,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":0,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":0},{"AccountName":"LL12345601","Currency":"USD","LastAsset":0,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":0,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":0},{"AccountName":"QS1001101","Currency":"USD","LastAsset":0,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":0,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":0},{"AccountName":"qwert01","Currency":"USD","LastAsset":0,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":0,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":0},{"AccountName":"QS1001301","Currency":"USD","LastAsset":0,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":0,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":0},{"AccountName":"LLL66601","Currency":"USD","LastAsset":0,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":0,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":0},{"AccountName":"GT31501","Currency":"USD","LastAsset":0,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":0,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":0},{"AccountName":"LLL33301","Currency":"USD","LastAsset":0,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":0,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":0},{"AccountName":"XXX11101","Currency":"USD","LastAsset":0,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":0,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":0},{"AccountName":"QS1002601","Currency":"USD","LastAsset":0,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":0,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":0},{"AccountName":"QS1002501","Currency":"USD","LastAsset":0,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":0,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":0},{"AccountName":"simon00101","Currency":"USD","LastAsset":0,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":0,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":0},{"AccountName":"simon00201","Currency":"USD","LastAsset":0,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":0,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":0},{"AccountName":"QS1002801","Currency":"USD","LastAsset":87358.7465536635,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":474273.578039372,"CurrentNLV":561632.324593036,"InitialMargin":85669.9568404064,"MaintenanceMargin":82645.9568404064,"BuyingPower":475962.367752629},{"AccountName":"QS1002901","Currency":"USD","LastAsset":36243.6369539975,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":-3567.01713293043,"CurrentNLV":32676.619821067,"InitialMargin":36077.9255599266,"MaintenanceMargin":36032.9255599266,"BuyingPower":-3401.30573885953},{"AccountName":"qwert101","Currency":"USD","LastAsset":0,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":0,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":0},{"AccountName":"QS1003101","Currency":"USD","LastAsset":107617467.336506,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":1446826.42960474,"CurrentNLV":109064293.766111,"InitialMargin":598095.212904397,"MaintenanceMargin":588425.212904397,"BuyingPower":108466198.553207},{"AccountName":"QS1003201","Currency":"USD","LastAsset":10668965.8686746,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":-138264.565744772,"CurrentNLV":10530701.3029298,"InitialMargin":1309860.96416975,"MaintenanceMargin":1305146.96416975,"BuyingPower":9220840.33876009},{"AccountName":"QS1003301","Currency":"USD","LastAsset":80134.8983312495,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":80134.8983312495,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":80134.8983312495},{"AccountName":"XXX22201","Currency":"USD","LastAsset":0,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":0,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":0},{"AccountName":"QS1003501","Currency":"USD","LastAsset":90916.1866219332,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":90916.1866219332,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":90916.1866219332},{"AccountName":"XXX33301","Currency":"USD","LastAsset":0,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":0,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":0},{"AccountName":"qwert201","Currency":"USD","LastAsset":0,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":0,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":0},{"AccountName":"QS1003801","Currency":"USD","LastAsset":87282.7932396997,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":87282.7932396997,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":87282.7932396997},{"AccountName":"QS1003901","Currency":"USD","LastAsset":59059.9763694601,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":59059.9763694601,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":59059.9763694601},{"AccountName":"QS1004001","Currency":"USD","LastAsset":91553.1348045799,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":91553.1348045799,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":91553.1348045799},{"AccountName":"QS1004101","Currency":"USD","LastAsset":81890.6614416781,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":81890.6614416781,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":81890.6614416781},{"AccountName":"qs10101","Currency":"USD","LastAsset":0,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":0,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":0},{"AccountName":"QS1004301","Currency":"USD","LastAsset":80708.9723457978,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":80708.9723457978,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":80708.9723457978},{"AccountName":"QS1004401","Currency":"USD","LastAsset":92357.6071268793,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":92357.6071268793,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":92357.6071268793},{"AccountName":"QS1004501","Currency":"USD","LastAsset":0,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":0,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":0},{"AccountName":"qs10201","Currency":"USD","LastAsset":0,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":0,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":0},{"AccountName":"QS1004701","Currency":"USD","LastAsset":0,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":0,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":0},{"AccountName":"QS1004801","Currency":"USD","LastAsset":0,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":0,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":0},{"AccountName":"QS1004901","Currency":"USD","LastAsset":0,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":0,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":0},{"AccountName":"QS1005001","Currency":"USD","LastAsset":0,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":0,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":0},{"AccountName":"qs000101","Currency":"USD","LastAsset":200000,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":200000,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":200000},{"AccountName":"qs000201","Currency":"USD","LastAsset":0,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":0,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":0},{"AccountName":"FRTEST0101","Currency":"USD","LastAsset":176333.632990647,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":12782.5,"CurrentNLV":189116.132990647,"InitialMargin":12500,"MaintenanceMargin":11900,"BuyingPower":145165.958886403},{"AccountName":"FRTEST0201","Currency":"USD","LastAsset":200000,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":200000,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":200000},{"AccountName":"FRTEST03","Currency":"USD","LastAsset":200000,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":200000,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":195765},{"AccountName":"whcj0101","Currency":"USD","LastAsset":0,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":0,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":0},{"AccountName":"whcj0201","Currency":"USD","LastAsset":0,"CashInOut":0,"OptionPremium":0,"Credit":0,"CustFee":0,"FutRealizedPL":0,"NetOptionValue":0,"FutUnRealizedPL":0,"CurrentNLV":0,"InitialMargin":0,"MaintenanceMargin":0,"BuyingPower":0}]}
            var result = new List<SettlementReportOutput>();

            // 创建 HTTP 绑定对象
            var binding = new BasicHttpBinding();
            //设置最大传输接受数量
            binding.MaxReceivedMessageSize = 2147483647;
            // 根据 WebService 的 URL 构建终端点对象
            var endpoint = new EndpointAddress(_options.BaseUrl);
            // 创建调用接口的工厂，注意这里泛型只能传入接口 添加服务引用时生成的 webservice的接口 一般是 (XXXSoap)
            var factory = new ChannelFactory<WebServiceAPISoap>(binding, endpoint);
            // 从工厂获取具体的调用实例
            var callClient = factory.CreateChannel();
            //调用的对应webservice 服务类的函数生成对应的请求类Body (一般是webservice 中对应的方法+RequestBody  如GetInfoListRequestBody)
            var body = new GetSettlementReportRequestBody();
            //以下是为该请求body添加对应的参数（就是调用webService中对应的方法的参数）
            body.loginUserName = loginUserName;

            //获取请求对象 （一般是webservice 中对应的方法+tRequest  如GetInfoListRequest）
            var request = new GetSettlementReportRequest(body);
            //发送请求
            var v = callClient.GetSettlementReportAsync(request);
            //异步等待
            v.Wait();
            //获取数据
            result = JsonConvert.DeserializeObject<List<SettlementReportOutput>>(v.Result.Body.GetSettlementReportResult);

            return result;
        }

        #endregion
    }
}
